package cn.shujuhai.meeting.util;

import cn.shujuhai.meeting.service.MeetingRoomsService;
import lombok.RequiredArgsConstructor;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Component;

/**
 * @Author: NiuYaHu
 * @Date: 2025/4/8 15:49
 * @Description:
 **/
@Component
@RequiredArgsConstructor
public class Meeting implements JavaDelegate {

    /**
     * 审批完成后切换会议室状态
     *
     * @param execution DelegateExecution对象，用于获取流程变量
     */
    @Override
    public void execute(DelegateExecution execution) {
        // 从流程变量中获取会议室ID和新状态
        String roomId = (String) execution.getVariable("roomId");
        String newStatus = (String) execution.getVariable("newStatus");

        // 调用服务层方法更新会议室状态
        UpdateMeetStatus.updateMeetStatus(Integer.valueOf(roomId), newStatus);
    }
}
